home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 025a / isamto.zip / ISAMTOOT.DOC < prev    next >
Text File  |  1991-11-05  |  11KB  |  267 lines

  1. ┌───────────────────────────────────────────────────────────────┐
  2. │           ISAMTOOT         -       WORKBOOK NOTES             │
  3. └───────────────────────────────────────────────────────────────┘
  4.  
  5. GENERAL
  6.  
  7. You need to have Microsoft's BASIC Professional Development System
  8. 7.0 or higher.  If when you installed PDS you didn't elect to
  9. install the ISAM "option" then you should re-run your installation
  10. to include it.
  11.  
  12. To avoid confusion we have deliberately avoided including any of
  13. the excellent libraries MS furnishes with PDS.  They ARE useful and
  14. important tools -- particularly in the later lessons -- but our
  15. judgement was that we wanted to focus on ISAM rather than expanding
  16. the study to the libraries as well.
  17.  
  18. We have also included some "bad" programming practices in the
  19. interests of simplicity and clarity.  (i.e., getting data with the
  20. LINE INPUT function.)  We've noted these "flaws" as we create them
  21. and you should flag them for further study and resolution -- again,
  22. our focus is ISAM, not programming in general.
  23.  
  24. ISAMTOOT was developed in PDS 7.1 on a system that accepted MS's
  25. "default" installation directories and sub directory structure(s).
  26.  
  27. When we call for a "DOS prompt" entry of -- say -- \bc7\bin\qbx, we
  28. are intending to start the PDS environment AND to be in the
  29. directory with QBX.EXE, etc. 
  30.  
  31. Technical support for this instructional course is available on
  32. CompuServe @ 70146,51, FAX: 817-488-4945, or 817-488-4940.  The
  33. telephones are answered 24 hours a day, 7 days a week.
  34.  
  35.  
  36. LESSON #1
  37.  
  38.      OBJECTIVE:  Create, dimension, open and add data to a bare
  39.      bones ISAM database.
  40.  
  41.      MS FILES NEEDED:  QBX.EXE, PROISAMD.EXE (Please note that we
  42.      are using the larger of the two TSR's MS furnishes -
  43.      PROISAMD.EXE, rather than PROISAM.EXE
  44.  
  45.                Comment:  The smaller of the TSR's does save
  46.                some memory, but you can't create indexes with
  47.                it and more importantly, the various utilities
  48.                MS furnishes to repair and pack database files
  49.                need to have PROISAMD.EXE rather than
  50.                PROISAM.EXE.  Certainly any commercial
  51.                application should use the "full featured"
  52.                version.
  53.  
  54.      TO START:  At the DOS prompt, type: PROISAMD and then press
  55.      your ENTER key.  Your system will display the message: 
  56.      "PROISAM successfully installed."
  57.  
  58.                (If you are continuing an adjourned lesson,
  59.                then the message might be:  "PROISAM already
  60.                installed."  To remove PROISAMD from memory
  61.                you should type (at the DOS prompt): PROISAMD
  62.                /D and press the ENTER key.)
  63.  
  64.      Now type:  QBX and press the ENTER key.  The screen should
  65.      clear and you find yourself in the programming
  66.      editor/environment.
  67.  
  68.  
  69. Step #1.  Type DEFINT A-Z and touch ENTER.
  70.  
  71. Step #2.  Touch an apostrophe    '    (to make this next line a
  72.           comment) and do a line of dashes.  (    -    )
  73.  
  74. Step #3.  Touch an apostrophe:    '    and type:    ISAMTOOT.L1
  75.  
  76.                You are correct in thinking that this file you are
  77.                creating -- the source code for lesson 1 -- would,
  78.                in the normal course of events have the extension: 
  79.                .BAS.  We have opted for this extension to maintain
  80.                uniformity within the course and avoid possible
  81.                damage of your other source code files.
  82.  
  83. Step #4.  Another apostrophe and another line of dashes.
  84.  
  85. Step #5.  Touch ENTER again to insert a blank line and then type: 
  86.           CLS.  (The first executable line of your program,
  87.           clearing the screen.)
  88.  
  89. Step #6.  Another blank line, then type:  TYPE lesson1data  
  90.  
  91.                We are beginning the actual defining of our first,
  92.                bare bones, database.  Don't be stingy with blank
  93.                lines, spaces, indenting, comments.  They cost you
  94.                nothing in a compiled program and the small
  95.                overhead they create within the environment is more
  96.                than paid back in clarity and ease of reading.
  97.  
  98. Step #7.  Define three fields -- all strings, all 35 characters
  99.           long.  The first is for the name, the second for the
  100.           address and the third for the city state and zip.
  101.  
  102. Step #8.  Type END TYPE
  103.  
  104.           Your finished definition block should look like:
  105.  
  106.                TYPE
  107.                     name AS STRING * 35
  108.                     address AS STRING * 35
  109.                     cityStateZip AS STRING * 35
  110.                END TYPE
  111.  
  112.           (Perfectly all right to peek at the ISAMTOOT.L1 source
  113.           code.  As a matter of fact, even though it is
  114.           considerably larger than the one you are writing, it will
  115.           run if you load it into QBX and do Shift+F5.)
  116.  
  117. Step #9.  Now we dimension  a variable for the lesson 1 data. 
  118.           Type:
  119.  
  120.                DIM lesson1record AS lesson1data
  121.  
  122. Step #10. Now we actually open the database and table . . . 
  123.  
  124.           OPEN "lesson1.MDB" FOR ISAM lesson1data "lesson1table"_
  125.           AS  #1
  126.  
  127.           (Please note that this is entered in a single line of
  128.           code.  The underscore:  _   is used to indicate that the
  129.           two lines are actually one.)
  130.  
  131. Step #11. We skip creation of an index for this first lesson, we'll
  132.           let ISAM use the one it creates when it adds records --
  133.           the null index.  It is automatically selected when none
  134.           other is specified.
  135.  
  136.           The database is now ready to receive some data, so we'll
  137.           set up a loop to gather information from the operator.
  138.  
  139. Step #12. Type in the following structure:
  140.  
  141.           DO
  142.  
  143.                CLS 
  144.                PRINT , , "There are "; LOF(1); " records in _ 
  145.                           the file."
  146.                PRINT     
  147.                PRINT , : LINE INPUT "First & Last Name: ";_
  148.                                     lesson1record.name
  149.                PRINT , : LINE INPUT "          Address: ";_
  150.                                     lesson1record.address
  151.                PRINT , : LINE INPUT "City, State & Zip: ";_
  152.                                     lesson1record.cityStateZip
  153.                PRINT     
  154.                PRINT , "<S>ave    -    <E>dit      -       <Q>uit"
  155.                PRINT , "     Touch  S   or    E    or     Q"
  156.  
  157.                dataDecision$ = UCASE$(INPUT$(1))
  158.  
  159.                IF dataDecision$ = "S" THEN
  160.                     INSERT #1, lesson1record
  161.                     LOCATE 25, 40: PRINT " Saved ";
  162.                     SLEEP 1
  163.                     EXIT DO
  164.                     END IF
  165.  
  166.           LOOP UNTIL dataDecision$ = "Q"
  167.  
  168. Step #13. That structure is about as rudimentary as you can get. 
  169.           LINE INPUT is not a good way to get data into a program
  170.           because the operator can enter anything, up to 32,000+
  171.           bytes, and doesn't return control to the program until
  172.           they press ENTER.  It serves our purposes here, but
  173.           invites trouble in anything other than an "author-
  174.           operated" situation.
  175.  
  176.           It's no fun to enter data unless you can see the "fruits
  177.           of your labor," so, to wrap up lesson one, lets take a
  178.           look at what we've entered in the database.
  179.  
  180. Step #14. Let's clear the screen and then write another loop to
  181.           look at our data . . . 
  182.  
  183.           CLS
  184.           PRINT
  185.           PRINT , "Total records now in the file: "; LOF(1)
  186.           PRINT
  187.           PRINT , "Now, we report the contents of the file . . . "
  188.           PRINT
  189.  
  190.           MOVEFIRST #1
  191.  
  192.           DO UNTIL EOF(1)
  193.                RETRIEVE #1, lesson1record 
  194.                PRINT , lesson1record.name 
  195.                PRINT , lesson1record.address       
  196.                PRINT , lesson1record.cityStateZip  
  197.                PRINT , "------------------------------------------"
  198.                SLEEP 1
  199.                MOVENEXT #1
  200.           LOOP
  201.  
  202. Step #15. This will display all the records in the database and
  203.           then the program will end.  With Shift+F5, you can re-
  204.           start the program (it will show the number of records in
  205.           the file), enter another record, save it and then it will
  206.           fall through this "reporting loop" to show you everything
  207.           you've entered.  Again stopping after reporting all the
  208.           records.
  209.  
  210.           Polishing things up a bit would mean you would type in
  211.           the following . . . 
  212.  
  213.  
  214.  
  215.           PRINT
  216.           PRINT , "We've reached the end of the file."
  217.           PRINT
  218.           PRINT , "Press Shift+F5 to restart, enter a"
  219.           PRINT , "record and report file contents."
  220.           PRINT
  221.           PRINT
  222.           END            
  223.  
  224.  
  225. SUMMARIZING THE LESSON:  You created and added records to an ISAM
  226.                          database.  While rudimentary, the program
  227.                          you wrote will, in fact, manage data for
  228.                          you.  
  229.  
  230.                          If you substitute LPRINT statements for
  231.                          the PRINT statements in the "reporting
  232.                          loop" you can get hard copy of your data.
  233.  
  234.  
  235. LOOKING AHEAD            To be really useful, your database needs
  236.                          to become more intricate.  As it stands
  237.                          now you wouldn't be able to sort to last
  238.                          name or city or even zip code (as the
  239.                          post office requires for bulk mailings.)
  240.  
  241.                          In Lesson #2, we will correct those
  242.                          shortcomings AND we will be adding
  243.                          INDEXES so that you can order your data
  244.                          in more useful ways.
  245.  
  246.                          This lesson will seem very much like "See
  247.                          Spot run." by the time you are managing
  248.                          tables of 15-20 fields each and then
  249.                          relating (as in relational database) the
  250.                          data in distinctively different tables.
  251.  
  252.                          Just keep your dial set right here!
  253.  
  254.  
  255.  
  256. EDITOR'S NOTE:  The file:  ISAMTOOT.ENR has complete pricing
  257. information for the full ten (10) lesson tutorial on ISAM.  The
  258. course is offered with an unusual money back guarantee of
  259. satisfaction:  If you are not delighted with the Course, just
  260. return the materials for a prompt, no hassle refund.
  261.  
  262.  
  263. Entire Contents Copyright 1991, Kirk Woodward d/b/a People Centered
  264. Programs, PO Box 610171, Dallas, TX 75261-0171.  CompuServe
  265. 70146,51 . Enrollments ONLY: 1-800-553-5883 . FAX: 817-488-4945 
  266. Voice: 817-488-4940
  267.                        isamtoot.doc = wp51 /isamdoc.asc = ASCII